#!/usr/bin/perl -w # for syntax highlighting
# CSS-V1

# Take all the args and update portal ... and then
# redirect to page in the LP parameter.
use gri_secmgr qw(get_cookie_value redirect_header);
use gri_user_alert_config;
use gri_portal_config;
use Data::Dumper;

sub mm_form_alter_user_access_process {
	my $uid=$::PARAM{"uid"};

	#################################################################
	# Ok we need to check for RR_role values and change the list of	#
	# users for the portal to that list.				#
	#################################################################

	my @roles=();
	for my $ckey (keys %::PARAM) {
		my ($role)=($ckey =~ /^RR_(.*)/);
		push @roles,$role if(defined($role) && $::PARAM{$ckey}==1);
	}

	my ($rc,$err)=$::GRI_FRONTEND->write_user_role($uid,[@roles]);
	if($rc==0) {
		my $serror="Error Changing User Capabilities";
		my $error=$err;

		my $link=link_to_str("","","show_generic_error","?serror=".string_to_hex($serror).",error=".string_to_hex($error));
		# We need to encode the current data for repopulation into the form!
		my $s="";
		$s.="uid=$uid";
		# $s.="::portal_filename=".string_to_hex($portal_filename);
		# $s.="::portal_users=".string_to_hex($portal_users);
		# $s.="::portal_template=".string_to_hex($portal_template);
		$link.=",previouspage=form_alter_user_access::$s";
		redirect_header(path => $link);
		exit;
	}

	my $link=link_to_str("","","/admin_page","");
	redirect_header(path => $link);
	exit;
}

1;

